package com.fenghongzhang.a1811;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;

public class MyDialog extends Dialog {

    private static final String TAG = "MyDialog";

    private TextView title;
    private TextView message;
    private Button no;
    private Button yes;
    public MyDialog(@NonNull Context context) {
        super(context);
    }

    private String strNo;

    public String getStrNo() {
        return strNo;
    }

    public void setStrNo(String strNo) {
        this.strNo = strNo;
    }

    //1,声明接口
    public interface YesOnClick{
        void onClick();
    }
    //2声明生成属性
    private YesOnClick yesOnClick;
    //3给接口赋值
    public void setYesOnClick(YesOnClick yesOnClick) {
        this.yesOnClick = yesOnClick;
    }

    //1,声明接口
    public interface NoOnClick{
        void click();
    }

    private NoOnClick noOnClick;

    public void setNoOnClick(NoOnClick noOnClick) {
        this.noOnClick = noOnClick;
    }

    //中间值
    private String strTitle;

    public String getStrTitle() {
        return strTitle;
    }

    public void setStrTitle(String strTitle) {
        this.strTitle = strTitle;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mydialog_layout);


        title = (TextView) findViewById(R.id.title);
        message = (TextView) findViewById(R.id.message);
        no = (Button) findViewById(R.id.no);
        yes = (Button) findViewById(R.id.yes);

        title.setText(strTitle);
        no.setText(strNo);


        yes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                yesOnClick.onClick();
                dismiss();
            }
        });

        no.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                noOnClick.click();
                dismiss();
            }
        });

    }
}
